package br.com.lambdacore.ui.stripes.action;

import net.sourceforge.stripes.action.ActionBeanContext;
import net.sourceforge.stripes.action.DefaultHandler;
import net.sourceforge.stripes.action.DontValidate;
import net.sourceforge.stripes.action.ForwardResolution;
import net.sourceforge.stripes.action.RedirectResolution;
import net.sourceforge.stripes.action.Resolution;
import br.com.lambdacore.ui.stripes.resolution.PageResolution;

public class LambdaCoreActionBean implements LambdaCoreAction {

	private ActionBeanContext actionBeanContext;

	@Override
	public LambdaCoreActionBeanContext getContext() {
		return (LambdaCoreActionBeanContext) this.actionBeanContext;
	}

	@Override
	public void setContext(ActionBeanContext actionBeanContext) {
		this.actionBeanContext = actionBeanContext;
	}

	@DontValidate
	@DefaultHandler
	@Override
	public Resolution index() {
		return this.forward();
	}

	protected Resolution forward() {
		return new PageResolution(this);
	}

	protected Resolution forward(Class<? extends LambdaCoreAction> action) {
		return new ForwardResolution(action);
	}

	protected Resolution forward(Class<? extends LambdaCoreAction> action, String event) {
		return new ForwardResolution(action, event);
	}

	protected Resolution forward(String eventName) {
		return new PageResolution(this, eventName);
	}

	protected Resolution redirect(Class<? extends LambdaCoreAction> action) {
		return new RedirectResolution(action);
	}

	protected Resolution redirect(Class<? extends LambdaCoreAction> action, String event) {
		return new RedirectResolution(action, event);
	}

	protected Resolution indexForward() {
		return this.forward("index");
	}

}
